package zhongbo.java.air.flightpath.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import zhongbo.java.air.flightpath.config.RedisListenerConfig;

@Component
@Slf4j
public class RedisLogChanelPublisher {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    //发布消息到频道
    public void publishMessage(String message) {
        try {
            redisTemplate.convertAndSend(RedisListenerConfig.LIVE_FLIGHT, message);
            log.debug("频道：{},已发布日志消息: {}",RedisListenerConfig.LIVE_FLIGHT,message);
        } catch (Exception e) {
            log.error("发布Redis日志消息失败", e);
        }
    }
}
